package collection;

import java.util.*;

/**
 * 排序List集合
 */
public class SortListDemo {
    public static void main(String[] args) {
        Random random = new Random();
        //创建一个List集合，存入10个0-100之间的随机整数
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(random.nextInt(100));
        }
        System.out.println(list);
//        Collections.sort(list);
        //降序
        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });


        System.out.println(list);
    }
}
